warning('off')
load('BloombergData20240205Govt.mat')
clear ind;
for i=1:length(AllDates)
    ind(i)=sum(abs(bonddat(i,2,1:63)))>0;
end
AllDates2=AllDates(ind);
bonddat2=bonddat(ind,:,:);

res=zeros(days1+days2+1,29,3);
nor=1;
for TwinNo=1:9
    TwinBonds_v2_update
    twob=squeeze(bonddat2(:,yno,[blackbond greenbond]))';
    wey=sum(twob.*Outstanding')./sum(Outstanding');
    black=twob(1,:);
    green=twob(2,:);
    Ned=length(ed);   
    for i=1:Ned
        eday=min(find(AllDates2>=ed(i)));
        res(:,nor,1)=wey(eday-days1:1:eday+days2)-bonddat2(eday-days1:1:eday+days2,yno,controlbond)';
        res(:,nor,2)=black(eday-days1:1:eday+days2)-bonddat2(eday-days1:1:eday+days2,yno,controlbond)';
        res(:,nor,3)=green(eday-days1:1:eday+days2)-bonddat2(eday-days1:1:eday+days2,yno,controlbond)';
        nor=nor+1;
    end
end
res=100*res;
